package com.douqu.game.core.config.major;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.util.LoadUtils;
import com.douqu.game.core.util.LogUtils;

import java.util.Arrays;

/**
 * @author wangzhenfei
 *         2017-11-28 16:03
 *         专业加技能
 */
public class MajorConfig extends GameObject {
    /**锻造经验**/
    public int forgingExp;
    /**挖掘经验**/
    public int excavateExp;
    /**采集经验**/
    public int collectExp;
    /**炼制经验**/
    public int refiningExp;
    /**采集产出**/
    public GoodsData[] collectOutput;
    /**采集额外增加的产出**/
    public int collectExtraRate;


    @Override
    public boolean check()
    {
        if(collectOutput == null)
        {
            LogUtils.error("MajorConfig check goods is null -> id:" + id + " name:" + name);
        }
        return true;
    }


    @Override
    public boolean setVariable(String key, String value)
    {
        if("collectOutput".equals(key))
        {
            collectOutput = LoadUtils.loadGoodDataToArray(key, value);
            return LoadUtils.checkGoods(collectOutput, this.getClass(), key, id);
        }
        else
            return super.setVariable(key, value);
    }

    @Override
    public String toString() {
        return "MajorConfig{" +
                "forgingExp=" + forgingExp +
                ", excavateExp=" + excavateExp +
                ", collectExp=" + collectExp +
                ", refiningExp=" + refiningExp +
                ", collectOutput=" + Arrays.toString(collectOutput) +
                "} " + super.toString();
    }
}
